<template>
  <div class="charts-page">
    <div class="top-bg"></div>
    <div class="list-wrap">
      <div class="title">
          <span>名次</span>
          <span>名称</span>
          <span>编号</span>
          <span>票数</span>
        </div>
      <ul class="list">        
        <li class="item" v-for="prettyGirl in prettyGirls" :key="prettyGirl.id">
          <span :class="{import: (prettyGirl.sort == 1) || (prettyGirl.sort == 2) || (prettyGirl.sort == 3)}">{{prettyGirl.sort}}</span>
          <span>{{prettyGirl.nickName}}</span>
          <span>{{prettyGirl.number}}</span>
          <span>{{prettyGirl.vote}}</span>
        </li>
      </ul>
      <a v-show="!isComplete" class="more" @click="loadMore">查看更多</a>
      <p v-show="isComplete" class="list-info">已经到底啦</p>
    </div>
  </div>
</template>

<script>
import { decodeUnicode } from '../libs/app'

export default {
  name: 'Charts',
  data () {
    return {
      prettyGirls: [],
      condition: {
        page: 1,
        size: 100
      },
      isComplete: false
    }
  },
  methods: {
    queryList () {
      this.$http.complexPost('/beautyPageantController/getBeautyRank', this.condition).then((data) => {

        if(data.lastPageNumber) {
          this.isComplete = true
        }

        data = data.content
        for(let i=0,len=data.length; i<len; i++) {
          // TODO: 接口 beautyPictures null
          this.prettyGirls.push({
            id: data[i].id,
            number: data[i].id,
            nickName: decodeUnicode(data[i].signName),
            vote: data[i].voteNum,
            sort: data[i].sort
          })
        }
      })
    },
    loadMore () {
      this.condition.page++
      this.queryList()
    }
  },
  mounted () {
    this.queryList()
  }
}
</script>

<style scoped>
.charts-page {
  min-height: 100%;
}
.charts-page .top-bg {
  height: 458px;
  background-image: url(../../static/img/charts-top-bg.png);
  background-repeat: no-repeat;
  background-position: top center;
  background-size: cover;
}
.charts-page .list-wrap {
  position: relative;
  top: -50px;
}
.charts-page .title {
  position: relative;
  top: 20px;
  height: 161px;
  display: flex;
  display: -webkit-flex;
  justify-content: space-around;
  align-items: center;
  background-image: url(../../static/img/subtitle-bg.png);
  background-repeat: no-repeat;
  background-position: bottom center;
  background-size: contain;
  padding: 0 35px;
}
.charts-page .title span {
  position: relative;
  top: 25px;
  font-size: 26px;
  color: #fff;
  width: 25%;
}
.charts-page .list {
  padding: 0 15px;
  background-color: #f1e1ff;
  width: 90%;
  margin: 0 auto;
  padding-top: 30px;
  padding-bottom: 30px;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
}
.charts-page .list li {
  display: flex;
  display: -webkit-flex;
  justify-content: space-around;
  align-items: center;
  min-height: 100px;
}
.charts-page .list li span {
  width: 25%;
  font-size: 28px;
  color: #333;  
  line-height: 100px;
  display: block;
  overflow: hidden; 
  text-overflow: ellipsis; 
  -o-text-overflow: ellipsis;
  white-space:nowrap;
}
.charts-page .list li span:first-child {
  color: #999;
}
.charts-page .list li span.import {
  color: #d40202;
}
.charts-page .more,
.charts-page .list-info {
  font-size: 24px;
  color: #b769ff;
  display: inline-block;
  margin: 25px auto;
}
</style>


